class Solution
{
public:
    int beautifulSubstrings(string s, int k)
    {
        int n = s.size();
        vector<int> prefixVolwels(n + 1, 0);
        for (int i = 0; i < n; ++i)
        {
            prefixVolwels[i + 1] = prefixVolwels[i] + (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' ||
                                                       s[i] == 'u');
        }
        int ans = 0;
        for (int i = 0; i < n; ++i)
        {
            for (int j = i; j < n; ++j)
            {
                int len = j - i + 1;
                int volwels = prefixVolwels[j + 1] - prefixVolwels[i];
                if (len == 2 * volwels && volwels * volwels % k == 0)
                {
                    ++ans;
                }
            }
        }
        return ans;
    }
};